package com.qf;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

class MyCallable<String> implements Callable<String>{


    public String call() throws Exception {
        return (String) "success";
    }
}


public class Callable_FutureTask {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        Callable callable = new MyCallable<Object>();
        FutureTask<Object> futureTask = new FutureTask<Object>(callable);
        Thread thread1=new Thread(futureTask, "线程A");
        System.out.println("当前运行的线程名:"+Thread.currentThread().getName());
        thread1.start();
        Object o = futureTask.get();
        System.out.println(o);

    }
}
